<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@include file="/WEB-INF/views/include/head.jsp" %>
<html>
<head>
	<title>任务管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			$("#uploadDocument").click(function(){
				if($(this).is(':checked')){
					$('#fileuploadDiv').show();
				}else{
					$('#fileuploadDiv').hide();
				}
			});
			if($("#uploadDocument").is(':checked')){
				$('#fileuploadDiv').show();
			}else{
				$('#fileuploadDiv').hide();
			}
			$('#fileuploadDiv').fileupload({
				url:"${ctx}/pro/projectTask/upload"
			}).bind('fileuploaddone', function (e, data){
				var resultJson = eval('('+data.result+')');
				if(resultJson.result=="true"){
					$("#items").val($("#items").val()+resultJson.name+",");
					$("#realNames").val($("#realNames").val()+resultJson.realName+",");
				}
			});  
		});
		function submitForm(){                                      //子窗体页面的保存数据方法 通过ajax
            if($("#inputForm").valid()){
                var url = "${ctx}/pro/projectTask/save";
                $.ajax({
                    type: 'POST',
                    url : url,
                    async:false,
                    data: $('#inputForm').serialize(),             //获取表单数据
                    success : function(data) {
                            alert("保存成功");
                            parent.$('#btn').click();
                            parent.$.jBox.close(true);
                            
                            /* window.parent.page();                                     //调用父窗体方法，当关闭子窗体刷新父窗体
                            window.parent.window.jBox.close(); */            //关闭子窗体
                    },
                    error : function(data){
                    	alertx("无权限");
                    }
                });
            }
        }
	</script>
</head>
<body>
	<%-- <ul class="nav nav-tabs">
		<li><a href="${ctx}/pro/projectTask/?taskGroup.id=${projectTask.taskGroup.id}">任务列表</a></li>
		<li class="active"><a href="${ctx}/pro/projectTask/form?id=${projectTask.id}&taskGroup.id=${projectTask.taskGroup.id}">任务<shiro:hasPermission name="pro:projectTask:edit">${not empty projectTask.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="pro:projectTask:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/> --%>
	<form:form id="inputForm" modelAttribute="projectTask" action="${ctx}/pro/projectTask/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<input id="taskGroupId" name="taskGroup.id" value="${projectTask.taskGroup.id}" type="hidden"/>
		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">所属项目：</label>
			<div class="controls">
			<input id="name" value="${projectTask.project.name}" type="text" class="input-medium" disabled="disabled"/>
			</div>
		</div>		
		<div class="control-group">
			<label class="control-label">任务名称：</label>
			<div class="controls">
				<%-- <form:input path="name" disabled="disabled" htmlEscape="false" maxlength="64" class="input-xlarge "/> --%>
				<input id="name" value="${projectTask.name}" type="text" class="input-medium" disabled="disabled"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">负责人：</label>
			<div class="controls">
				<sys:treeselect id="manager" disabled="disabled" name="manager.id" value="${projectTask.manager.id}" labelName="manager.name" labelValue="${projectTask.manager.name}"
					title="用户" url="/sys/office/treeData?type=3" cssClass="" allowClear="true" notAllowSelectParent="true"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">优先级：</label>
			<div class="controls">
				<input id="name" value="${fns:getDictLabel(projectTask.priority,'task_priority',0)}" type="text" class="input-medium" disabled="disabled"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">开始时间：</label>
			<div class="controls">
				<input name="startTime" disabled="disabled" id="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${projectTask.startTime}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false,minDate:'%y-%M-%d',maxDate:'#F{$dp.$D(\'endTime\')}'});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">结束时间：</label>
			<div class="controls">
				<input name="endTime" disabled="disabled" id="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${projectTask.endTime}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false,minDate:'#F{$dp.$D(\'startTime\')}'});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">任务描述：</label>
			<div class="controls">
				<textarea rows="2" cols="" value="${projectTask.remarks}" disabled="disabled" maxlength="1000" class="input-xxlarge "></textarea>
			</div>
		</div>
		<%-- <div class="control-group">
			<label class="control-label">任务状态：</label>
			<div class="controls">
				<form:select path="status" class="input-xlarge ">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('task_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</div>
		</div> --%>
		<%-- <div class="control-group">
			<label class="control-label">是否上传文档：</label>
			<div class="controls">
				<input id="uploadDocument" type="checkbox" name="uploadDocument" value="1" <c:if test="${projectTask.uploadDocument == 1}">checked</c:if>/>
			</div>
		</div>
		<div id="fileuploadDiv" class="control-group">
			<label class="control-label">上传文档：</label>
			<div class="controls">
				    <input id="fileupload" type="file" name="file" data-url="${ctx}/pro/projectTask/upload" multiple>   
				    <input id="items" name="items" value="" type="hidden"/>
				    <input id="realNames" name="realNames" value="" type="hidden"/>
			</div>
		</div> --%>
		<%-- <div class="form-actions">
			<shiro:hasPermission name="pro:projectTask:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<!-- <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/> -->
		</div> --%>
	</form:form>
</body>
</html>